package com.java.mapper;

import com.java.entity.Profile;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProfileMapper {
    @Select("SELECT * FROM profile ORDER BY create_time DESC")
    List<Profile> selectAll();

    @Insert("INSERT INTO profile(name, device_type, protocol, create_time) VALUES(#{name}, #{deviceType}, #{protocol}, now())")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Profile profile);

    @Select("SELECT * FROM profile WHERE id=#{id}")
    Profile selectById(Long id);
    @Delete("DELETE FROM profile WHERE id =#{profileId}")
    void deleteById(Long id);

    @Update("UPDATE profile SET name = #{name}, device_type = #{deviceType}, protocol = #{protocol} WHERE id = #{id}")
    int updateById(Profile profile);
}